package com.vlh.battleship.server.common;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CommonFunctions {
	public static String encode(String t) {
		String r = "";
		try {
			MessageDigest sha1 = MessageDigest.getInstance("SHA1");
			byte[] data = t.getBytes("UTF-8");
			byte[] hash = sha1.digest(data);
			for (byte b : hash) r += b;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return r;
	}
}
